﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SEBanking
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["UserID"] = String.Empty;
            Session["UserName"] = String.Empty;
            Session["UserTypeID"] = -1;
        }

        protected void LoginForm_Authenticate(object sender, AuthenticateEventArgs e)
        {
            ServiceReferenceSEBanking.Service1Client sw = new ServiceReferenceSEBanking.Service1Client();
            ServiceReferenceSEBanking.User u = sw.CheckAccount(LoginForm.UserName, LoginForm.Password);
            if (u == null)
            {
                LoginForm.FailureText = "The username or password you entered is incorrect.";
            }
            else
            {
                Session["UserID"] = u.UserID;
                Session["UserName"] = u.UserName;
                Session["UserTypeID"] = u.UserTypeID;
                if (u.UserName == "Admin")
                    Response.Redirect("~/Admin/ManageUsers.aspx");
                else
                    Response.Redirect("~/Member/Index_Member.aspx");
            }
        }
    }
}
